New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

number-steps

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

number-steps

```js const {step} = require("./number-steps");

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

number-steps

const {step} = require("./number-steps");

describe("number-steps", () => {
    describe("Bugs", () => {
        it("should handle the -1 case correctly", () => {
            expect(step({size : 1, snap: true}).down(-1)).toBe(-2)
        });
        it("should handle the 1 case correctly", () => {
            expect(step({size : 1, snap: true}).up(1)).toBe(2)
        });
    })

    describe("Happy Case", () => {
        it("should resolve non-snapped steps correctly", () => {
            expect(step({size : 50}).up(23)).toBe(73)
            expect(step({size : 50}).up(-23)).toBe(27)
            expect(step({size : 50}).down(23)).toBe(-27)
            expect(step({size : 50}).down(-23)).toBe(-73)
        })

        it.each`value | expected
        ${-23} | ${0}
        ${-100}| ${-50}
        ${-115}| ${-100}
        ${-145}| ${-100}
        ${-150}| ${-100}
        ${-155}| ${-150}
        ${-200}| ${-150}
        ${-250}| ${-200}
        ${0}| ${50}
        ${23}| ${50}
        ${115}| ${150}
        ${145}| ${150}
        ${150}| ${200}
        `("should resolve the snapped up steps for $value and step size 50 correctly", ({value, expected}) => {
            expect(step({size : 50, snap: true}).up(value)).toBe(expected)
        })

        it.each`value | expected
        ${-23} | ${0}
        ${-115}| ${-92}
        ${-145}| ${-138}
        ${-155}| ${-138}
        ${0}| ${23}
        ${23}| ${46}
        ${116}| ${138}
        ${145}| ${161}
        `("should resolve the snapped up steps for $value and step size 23 correctly", ({value, expected}) => {
            expect(step({size : 23, snap: true}).up(value)).toBe(expected)
        })

        it.each`value | expected
        ${-23} | ${-50}
        ${-115}| ${-150}
        ${-145}| ${-150}
        ${-150}| ${-200}
        ${-155}| ${-200}
        ${0}| ${-50}
        ${23}| ${0}
        ${115}| ${100}
        ${145}| ${100}
        ${150}| ${100}
        ${155}| ${150}
        `("should resolve the snapped down steps for $value and step size 50 correctly", ({value, expected}) => {
            expect(step({size : 50, snap: true}).down(value)).toBe(expected)
        })
    })
})

FAQs

Package last updated on 10 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts