This file contains hidden or 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
| describe('ProductData.update', () => { | |
| it('can update data', () => { | |
| const context = await Database.InitiateWithOneProduct() | |
| const updatedProduct = await ProductData.update(context.product1.id, { name: 'new' }) | |
| expect(updatedProduct.name).toEqual('new') | |
| }) | |
| // ถ้าเทสแบบนี้เวลาเราแก้ ProductData.create ให้เป็นแบบอื่นจนฟังก์ชั่น Update ทำงานด้วยไม่ได้ เทสจะไม่พัง | |
| }) | |
| describe('ProductData.update', () => { |
This file contains hidden or 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
| class X { | |
| A(): void { | |
| const x = new Y() | |
| // Message | |
| const message = new Message() | |
| message.metadata = { data: "hello", data2: "world" } | |
| message.callback = () => console.log('Done') | |
| // Message | |
| x.B(message) | |
| } |
This file contains hidden or 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 MyComponent = (props) => { | |
| const appList = useSelector(state => state.apps.appList) | |
| const [sourceMenu, setSourceMenu] = useState(null) | |
| useEffect(() => { | |
| setSoureMenu(appList) | |
| }, [appList]) | |
| } |
This file contains hidden or 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
| class IEnumerable<T> | |
| { | |
| private List<T> data; | |
| public T Where((func T => bool) filterFunc) | |
| { | |
| for (var d in data) { | |
| if (filterFunc(d)) return d; | |
| } | |
| return null; | |
| } |
This file contains hidden or 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
| class OtherThing | |
| def initialize(input) | |
| @context = input.to_context | |
| end | |
| def do_stuff | |
| run_with @context.get_those | |
| end | |
| end |
This file contains hidden or 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
| function prepare(isAdmin) { | |
| if (isAdmin) { | |
| // เฉพาะ Admin | |
| } else { | |
| // ทำอีกแบบหนึ่ง | |
| } | |
| } | |
| function process(isAdmin) { | |
| if (isAdmin) { |
This file contains hidden or 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
| class DocumentXDomainModel { | |
| public static DocumentXDomainModel CreateFromPostRequest (WebRequest request) { | |
| // กรณีนี้ Validate ทุกฟิลด์ | |
| } | |
| public static DocumentXDomainModel CreateFromPatchRequest (WebRequest request) { | |
| // กรณีนี้อาจจะไป Get จากฐานข้อมูลมาก่อนเพื่อการันตีว่า Domain model มีิฟิลด์ครบ | |
| } | |
| } |
This file contains hidden or 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
| abstract class DocumentXRequest { | |
| Optional<int> field1; | |
| Optional<string> fiedl2; | |
| DocumentXDomainModel validate(); | |
| } | |
| class DocumentXCreateRequest: DocumentXRequest { | |
| DocumentXDomainModel validate() { | |
| // Validate create request |
This file contains hidden or 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
| test('requirement', () => { | |
| // ---------------------------- | |
| // Initialization, etc. | |
| // ---------------------------- | |
| return new Promise((resolve, reject) => { | |
| repo.once('data', () => { | |
| try { | |
| const savedFeature = repo.getToggle(feature.name); | |
| expect(savedFeature.enabled === feature.enabled).toBeTruthy(); | |
| expect(savedFeature.strategies[0].name === feature.strategies[0].name).toBeTruthy(); |
This file contains hidden or 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
| export function deQueueWaitingMatters( | |
| matterQueue: IWaitAnimatingMatter[], | |
| now = new Date() | |
| ): IDeQueueWaitingMattersResult { | |
| if (!isNeedAnimated(matterQueue, now)) { | |
| return { newQueue: matterQueue } | |
| } | |
| const nextAnimationTime = moment(now) | |
| .add(300, 'milliseconds') | |
| .toDate() |
NewerOlder