-
-
Save fhpriamo/79e17f8736d2bb08fa660bf1b6a17aa8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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