Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/generationtux/cufflink in…
Browse files Browse the repository at this point in the history
…to OP-266-teardown-command
  • Loading branch information
weklund committed Oct 19, 2016
2 parents 4e90711 + 738ab2e commit 98d4497
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 26 deletions.
7 changes: 3 additions & 4 deletions src/CreateCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ class CreateCommand {
let graph = this.dependencyGraph.run();
let drivers = this.driverLocator.drivers();

let result = {};
let result = [];

graph.forEach((graphElement) => {
let lowerElement = graphElement.toLowerCase();
let driver = drivers[lowerElement];
result[lowerElement] = driver.create();
let driver = drivers[graphElement.toLowerCase()];
result.push(driver.create());
});

this.fs.writeFileSync('./seededData.json', JSON.stringify(result));
Expand Down
56 changes: 34 additions & 22 deletions test/CreateCommandTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,28 @@ describe('Create command tests', () => {
let AccountDriver = {
create: function () {
return ({
'id': 1,
'firstName': 'Bob',
'lastName': 'Jones',
'email': 'bob@jones.com',
'type': 'account',
'properties': {
'id': 1,
'firstName': 'Bob',
'lastName': 'Jones',
'email': 'bob@jones.com'
}
});
}
};

let ContactDriver = {
create: function () {
return ({
'id': 1,
'firstName': 'Bob',
'lastName': 'Jones',
'email': 'bob@jones.com',
'accountId': 1
'type': 'contact',
'properties': {
'id': 1,
'firstName': 'Bob',
'lastName': 'Jones',
'email': 'bob@jones.com',
'accountId': 1
}
});
}
};
Expand Down Expand Up @@ -60,20 +66,26 @@ describe('Create command tests', () => {

createCommand.run();

expect(dataExpectedToBeWrittenToFile).to.equal(JSON.stringify({
'account': {
'id': 1,
'firstName': 'Bob',
'lastName': 'Jones',
'email': 'bob@jones.com',
expect(dataExpectedToBeWrittenToFile).to.equal(JSON.stringify([
{
'type': 'account',
'properties': {
'id': 1,
'firstName': 'Bob',
'lastName': 'Jones',
'email': 'bob@jones.com'
}
},
'contact': {
'id': 1,
'firstName': 'Bob',
'lastName': 'Jones',
'email': 'bob@jones.com',
'accountId': 1
{
'type': 'contact',
'properties': {
'id': 1,
'firstName': 'Bob',
'lastName': 'Jones',
'email': 'bob@jones.com',
'accountId': 1
}
}
}));
]));
});
});

0 comments on commit 98d4497

Please sign in to comment.