Sha256: d28bb94e44e5a65daef0c68dafcc668d9fb3018efdafdb27dbaec1d72dd18ab5

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

import AbstractApplicationTestCase from './abstract-application';
import { ModuleBasedResolver } from '../test-resolver';
import { Component } from 'ember-glimmer';
import { assign } from '@ember/polyfills';

export default class TestResolverApplicationTestCase extends AbstractApplicationTestCase {
  get applicationOptions() {
    return assign(super.applicationOptions, {
      Resolver: ModuleBasedResolver,
    });
  }

  add(specifier, factory) {
    this.resolver.add(specifier, factory);
  }

  addTemplate(templateName, templateString) {
    this.resolver.add(
      `template:${templateName}`,
      this.compile(templateString, {
        moduleName: `my-app/templates/${templateName}.hbs`,
      })
    );
  }

  addComponent(name, { ComponentClass = Component, template = null }) {
    if (ComponentClass) {
      this.resolver.add(`component:${name}`, ComponentClass);
    }

    if (typeof template === 'string') {
      this.resolver.add(
        `template:components/${name}`,
        this.compile(template, {
          moduleName: `my-app/templates/components/${name}.hbs`,
        })
      );
    }
  }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
discourse-ember-source-3.5.1.1 dist/es/internal-test-helpers/lib/test-cases/test-resolver-application.js
discourse-ember-source-3.5.1.0 dist/dist/es/internal-test-helpers/lib/test-cases/test-resolver-application.js