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 { Shop, Item, SpecialItemName } = require('../src/gilded_rose'); | |
const { ITEM_AGED_BRIE, ITEM_SULFURAS, ITEM_BACKSTAGE_PASS } = SpecialItemName; | |
describe('Gilded Rose', function() { | |
it('the item foo should degrade both its quality and sellIn day', function() { | |
const gildedRose = new Shop([new Item('foo', 10, 10)]); | |
const items = gildedRose.updateQuality(); | |
const testItem = items[0]; | |
expect(testItem.name).toBe('foo'); |
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
e-commerce | |
├── catalog | |
│ ├── applicationService | |
│ │ ├── AddProduct.ts | |
│ │ ├── DeleteProduct.ts | |
│ │ └── UpdateProduct.ts | |
│ ├── domain | |
│ │ ├── event | |
│ │ │ ├── ProductCreated.ts | |
│ │ │ └── ProductUpdated.ts |
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
/** | |
* @param {number[]} nums | |
* @returns {Left|Right} | |
*/ | |
function sumPositiveNums(nums) { | |
if (nums.some(num => !Number.isInteger(num))) { | |
return Left.of({ code: 501, msg: 'All numbers should be integer' }); | |
} | |
if (nums.some(num => num <= 0)) { | |
return Left.of({ code: 502, msg: 'All numbers should be positive'}); |
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
/** | |
* --------------------------- | |
* Domain Layer | |
* --------------------------- | |
*/ | |
class Order { | |
/** | |
* | |
* @param {Object} prop | |
* @param {string} prop.id |
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 { ApolloServer, gql } = require('apollo-server') | |
const DataLoader = require('dataloader') | |
const sqlite3 = require('sqlite3').verbose() | |
const db = new sqlite3.Database(':memory:') | |
const { promisify } = require('util') | |
db.get = promisify(db.get) | |
db.all = promisify(db.all) | |
// run in serial | |
db.serialize(function () { |