Skip to content

Commit

Permalink
test(test): added test for EmberAppItem
Browse files Browse the repository at this point in the history
  • Loading branch information
gerard2perez committed Nov 11, 2016
1 parent e688eb5 commit 38d31f5
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/support/EmberAppItem.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
const EAIEnum = ['name', 'mount', 'directory', 'access', 'adapter', 'subdomain', 'layout'];
const DefEAIEnum = ['emberapp', '/', '/emberapp', 'public', 'localhost', 'www', 'main'];
const Defaults = {
'name': 'emberapp',
'mount': '/',
'directory': '/emberapp',
'access':'public',
'adapter':'localhost',
'subdomain':'www',
'layout':'main'
}

export default class EmberAppItem {
constructor(application, data) {
data.name = application;
for (let property of EAIEnum) {
constructor(...args) {
let [application, data] = args;
data = Object.assign({},Defaults,data||{});
data.name = application || Defaults.name;
for (let property in Defaults) {
Object.defineProperty(this, property, {
enumerable: property !== 'name',
value: data[property] || DefEAIEnum[property]
value: data[property]
});
}
Object.freeze(this);
Expand Down
37 changes: 37 additions & 0 deletions test/unit/support/EmberAppItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*global describe, it*/
import * as assert from 'assert';
import EmberAppItem from '../../../src/support/EmberAppItem';

describe('EmberAppItem', function() {
let App = new EmberAppItem();
it('creates EmberApp Default config', function() {
assert.equal(App.name,'emberapp');
assert.equal(App.mount,'/');
assert.equal(App.directory,'/emberapp');
assert.equal(App.access,'public');
assert.equal(App.adapter,'localhost');
assert.equal(App.subdomain,'www');
assert.equal(App.layout,'main');
});

it('creates EmberApp with config', function() {
App = new EmberAppItem('test',{mount:'/panel'});
assert.equal(App.name,'test');
assert.equal(App.mount,'/panel');
assert.equal(App.directory,'/emberapp');
assert.equal(App.access,'public');
assert.equal(App.adapter,'localhost');
assert.equal(App.subdomain,'www');
assert.equal(App.layout,'main');
});

it('is equal if name are the same',function(){
let App2 = new EmberAppItem('test');

assert.equal(App.equals(App2),true);
});

it('returns app\' name',function(){
assert.equal(App.valueOf(),'test');
});
});

0 comments on commit 38d31f5

Please sign in to comment.