Skip to content

Instantly share code, notes, and snippets.

@PCreations
Created January 10, 2019 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save PCreations/d3a8ddabf3f75632e70987e08a98d16e to your computer and use it in GitHub Desktop.
Save PCreations/d3a8ddabf3f75632e70987e08a98d16e to your computer and use it in GitHub Desktop.
const { MyVeryUsefulProject } = require('../index');
const { getFooOfId, saveFoo } = require('../infrastructure/inMemory');
describe('Feature: updating bar', () => {
describe('scenario: updating bar with a value not containing a "?"', () => {
describe('given a foo object in database with the id foo1 and a bar value of "initial bar value"', () => {
describe('when updating the bar value to "some new value"', async (done) => {
test('then the foo object with id foo1 should have its bar value set to "some new value"', () => {
const inMemoryDatabase = {
foo1: {
id: foo1,
bar: 'initial bar value',
foobaz: 0
}
};
const myVeryUsefulProject = MyVeryUsefulProject({
getFooOfId: getFooOfId(inMemoryDatabase),
saveFoo: saveFoo(inMemoryDatabase),
});
await myVeryUsefulProject.updateBar({ fooId: 'foo1', bar: 'some new value' });
expect(inMemoryDatabase.foo1.bar).toBe('some new value');
done();
});
});
});
});
describe('scenario: updating bar with a value containing a "?"', () => {
describe('given a foo object in database with the id foo1 and a bar value of "initial bar value"', () => {
describe('when updating the bar value to "some other value ?"', async (done) => {
test('then the foo object with id foo1 should have its bar value set to "some other value ?" and its foobaz value set to 42', () => {
const inMemoryDatabase = {
foo1: {
id: foo1,
bar: 'initial bar value',
foobaz: 0
}
};
const myVeryUsefulProject = MyVeryUsefulProject({
getFooOfId: getFooOfId(inMemoryDatabase),
saveFoo: saveFoo(inMemoryDatabase),
});
await myVeryUsefulProject.updateBar({ fooId: 'foo1', bar: 'some other value ?' });
expect(inMemoryDatabase.foo1.bar).toBe('some other value ?');
expect(inMemoryDatabase.foo1.foobaz).toBe(42);
done();
});
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment