Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test] Resolver tests - lookupComponentPair #20830

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions packages/@ember/-internals/glimmer/tests/unit/resolver-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import QUnit from 'qunit';
import { lookupComponentPair } from '@ember/-internals/glimmer/lib/resolver';

QUnit.module('lookupComponentPair - Linha 106', function(){
QUnit.test('Test where isFactory is TRUE and component.class is TRUE', function(assert){
let component = {isFactory: true, class: true};
let layout = {someProperty: 'value'};

let result = lookupComponentPair(null, null, {component, layout});

assert.deepEqual(result, {component, layout}, 'Correct return when isFactory and component.class are TRUE.');
});

QUnit.test('Test where isFactory is TRUE e component.class is FALSE', function(assert){
let component = {isFactory: true, class: false};
let layout = {someProperty: 'value'};

let result = lookupComponentPair(null, null, {component, layout});

assert.equal(result, null, 'Return null when isFactory is TRUE and component.class is FALSE');
});

QUnit.test('Test where isFactory is FALSE and component.class is TRUE', function(assert){
let component = {isFactory: false, class:true};
let layout = {someProperty: 'value'};

let result = lookupComponentPair(null, null, {component, layout});

assert.equal(result, null, 'Return null when is Factory is FALSE and component.class is TRUE');
});

QUnit.test('Test layout defined', function(assert){
let component = {isFactory:true, class:true};
let layout = {someProperty: 'value'};

let result = lookupComponentPair(null, null, {component, layout});

assert.deepEqual(result, {component, layout}, 'Return correct when layout is defined');
});

QUnit.test('Test layout undefined', function(assert){
let component = {isFactory:true, class: true};
let layout = undefined;

let result = lookupComponentPair(null, null, {component, layout});

assert.equal(result, null, 'Return null when layout is undefined');
});

QUnit.test('Test of null component and null layout', function(assert){
let component = null;
let layout = null;

let result = lookupComponentPair(null, null, { component, layout });

assert.equal(result, null, 'Return null when component and layout are null');
})

QUnit.test('Test of null component and not null layout', function(assert){
let component = null;
let layout = { someProperty: 'value' };

let result = lookupComponentPair(null, null, { component, layout });

assert.deepEqual(result, {component:null, layout}, 'Return correct when component is null and not null layout');
});

QUnit.test('Test of not null component and null layout',function(assert){
let component = { isFactory: true, class: true };
let layout = null;

let result = lookupComponentPair(null, null, { component, layout });

assert.deepEqual(result, {component, layout:null}, 'Return correct when not null component and null layout');
});
});