describe("mock global date", ()=> {
beforeEach(async () => {
global.Date.now = jest.fn(() => new Date("2020-01-01T12:00:00Z").getTime());
});
afterAll(() => {
global.Date.now = RealDate;
});
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
type Brackets = { | |
min: number; | |
max: number; | |
rate: number; | |
}[]; | |
export const calculateIncomeTax = (salary: number, brackets: Brackets) => { | |
return brackets.reduce<number>((acc, b) => { | |
if (salary > b.min) { | |
const taxableAmount = Math.min(salary, b.max) - b.min; |
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
/** | |
* | |
Unreliable Webhook | |
There's a webhook that's calling webhookHandle that is unreliable. | |
It is possible that after it receives a paid status, it triggers a failed or paid one. | |
possible cases => | |
- pending → submitted → paid | |
- pending → submitted → failed | |
- pending → submitted → paid → paid |
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
<script> | |
export default { | |
data() { | |
return { | |
hasSlotContent: false, | |
} | |
}, | |
methods: { | |
checkForSlotContent() { | |
let checkForContent = (hasContent, node) => { |
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
// Axios.prototype cannot be modified | |
const axiosExtra = { | |
setBaseURL (baseURL) { | |
this.defaults.baseURL = baseURL | |
}, | |
setHeader (name, value, scopes = 'common') { | |
for (let scope of Array.isArray(scopes) ? scopes : [ scopes ]) { | |
if (!value) { | |
delete this.defaults.headers[scope][name]; | |
return |
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
#!/usr/bin/env node | |
var fs = require('fs') | |
var path = require('path') | |
var dom = require('cheerio') | |
var args = process.argv.slice(2) | |
var $ = dom.load( | |
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="0" height="0" style="display:none;"></svg>', | |
{ xmlMode: true } | |
) | |
var dir |
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
module.exports = { | |
root: true, | |
env: { | |
node: true | |
}, | |
extends: [ | |
"plugin:vue/recommended", | |
"eslint:recommended", | |
"prettier/vue", | |
"plugin:prettier/recommended" |
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
* { background-color: rgba(255,0,0,.2); } | |
* * { background-color: rgba(0,255,0,.2); } | |
* * * { background-color: rgba(0,0,255,.2); } | |
* * * * { background-color: rgba(255,0,255,.2); } | |
* * * * * { background-color: rgba(0,255,255,.2); } | |
* * * * * * { background-color: rgba(255,255,0,.2); } | |
* * * * * * * { background-color: rgba(255,0,0,.2); } | |
* * * * * * * * { background-color: rgba(0,255,0,.2); } | |
* * * * * * * * * { background-color: rgba(0,0,255,.2); } |
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
import { mount, createLocalVue } from "vue-test-utils"; | |
import { actions, mutations } from "~/test/mocks/store-actions-mutations.mock"; | |
import Component from "~/pages/index.vue"; | |
import Vuex from "vuex"; | |
const localVue = createLocalVue(); | |
localVue.use(Vuex); | |
const store = new Vuex.Store({ state, mutations, actions }); | |
const cmp = mount(Component, { | |
store, |
NewerOlder