-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Updated map and set specs. - Updated ReadMe.
- Loading branch information
Anthony Sneed
committed
Sep 15, 2017
1 parent
998493c
commit e23cd9d
Showing
4 changed files
with
179 additions
and
45 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { Product } from './models/product.spec'; | ||
import { TrackableSet } from './trackable-set'; | ||
import { TrackingState } from './tracking-state'; | ||
|
||
describe('TrackableEntity', () => { | ||
|
||
let product: Product; | ||
|
||
beforeEach(() => { | ||
product = new Product(1, 'Bacon', 1); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(product).toBeTruthy(); | ||
}); | ||
|
||
it('should set entity TrackingState to Modified when tracking', (done) => { | ||
|
||
// Arrange | ||
product.tracking = true; | ||
|
||
// Act | ||
product.productName = 'Peas'; | ||
|
||
// Assert | ||
expect(product.trackingState).toEqual(TrackingState.Modified); | ||
done(); | ||
}); | ||
|
||
it('should not set entity TrackingState to Modified when tracking but not changed', (done) => { | ||
|
||
// Arrange | ||
product.tracking = true; | ||
|
||
// Act | ||
product.productName = product.productName; | ||
|
||
// Assert | ||
expect(product.trackingState).toEqual(TrackingState.Unchanged); | ||
done(); | ||
}); | ||
|
||
it('should not set entity TrackingState to Modified when not tracking', (done) => { | ||
|
||
// Arrange | ||
product.tracking = true; | ||
|
||
// Act | ||
product.tracking = false; | ||
product.productName = 'Peas'; | ||
|
||
// Assert | ||
expect(product.trackingState).toEqual(TrackingState.Unchanged); | ||
done(); | ||
}); | ||
|
||
it('should add to entity ModifiedProperties when tracking', (done) => { | ||
|
||
// Arrange | ||
product.tracking = true; | ||
|
||
// Act | ||
product.productName = 'Peas'; | ||
product.unitPrice = 5; | ||
|
||
// Assert | ||
expect(product.trackingState).toEqual(TrackingState.Modified); | ||
expect(product.modifiedProperties.size).toEqual(2); | ||
expect(product.modifiedProperties.has('productName')).toBeTruthy(); | ||
expect(product.modifiedProperties.has('unitPrice')).toBeTruthy(); | ||
done(); | ||
}); | ||
}); |
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
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