Functional Weave
Code in Python

banking.cheque-amount-words@1.0.0

vectors.json

4,341 bytes · view raw

[
  {
    "name": "pounds and pence in words",
    "args": [
      {
        "minor": 123456,
        "currency": "GBP"
      },
      "words"
    ],
    "expect": {
      "words": "One thousand two hundred and thirty-four pounds and fifty-six pence only",
      "figures": "£1,234.56"
    }
  },
  {
    "name": "pounds and pence as figures",
    "args": [
      {
        "minor": 12050,
        "currency": "GBP"
      },
      "figures"
    ],
    "expect": {
      "words": "One hundred and twenty pounds and 50p only",
      "figures": "£120.50"
    }
  },
  {
    "name": "whole pounds leave the pence out in words",
    "args": [
      {
        "minor": 1000,
        "currency": "GBP"
      },
      "words"
    ],
    "expect": {
      "words": "Ten pounds only",
      "figures": "£10.00"
    }
  },
  {
    "name": "whole pounds leave the pence out as figures",
    "args": [
      {
        "minor": 1000,
        "currency": "GBP"
      },
      "figures"
    ],
    "expect": {
      "words": "Ten pounds only",
      "figures": "£10.00"
    }
  },
  {
    "name": "single pence are not padded",
    "args": [
      {
        "minor": 10005,
        "currency": "GBP"
      },
      "figures"
    ],
    "expect": {
      "words": "One hundred pounds and 5p only",
      "figures": "£100.05"
    }
  },
  {
    "name": "one pound and one penny",
    "args": [
      {
        "minor": 101,
        "currency": "GBP"
      },
      "words"
    ],
    "expect": {
      "words": "One pound and one penny only",
      "figures": "£1.01"
    }
  },
  {
    "name": "under a pound in words",
    "args": [
      {
        "minor": 50,
        "currency": "GBP"
      },
      "words"
    ],
    "expect": {
      "words": "Fifty pence only",
      "figures": "£0.50"
    }
  },
  {
    "name": "under a pound as figures still writes the pounds in words",
    "args": [
      {
        "minor": 50,
        "currency": "GBP"
      },
      "figures"
    ],
    "expect": {
      "words": "Zero pounds and 50p only",
      "figures": "£0.50"
    }
  },
  {
    "name": "the smallest cheque",
    "args": [
      {
        "minor": 1,
        "currency": "GBP"
      },
      "words"
    ],
    "expect": {
      "words": "One penny only",
      "figures": "£0.01"
    }
  },
  {
    "name": "British and after hundreds",
    "args": [
      {
        "minor": 10100,
        "currency": "GBP"
      },
      "words"
    ],
    "expect": {
      "words": "One hundred and one pounds only",
      "figures": "£101.00"
    }
  },
  {
    "name": "a million",
    "args": [
      {
        "minor": 100000000,
        "currency": "GBP"
      },
      "words"
    ],
    "expect": {
      "words": "One million pounds only",
      "figures": "£1,000,000.00"
    }
  },
  {
    "name": "euros",
    "args": [
      {
        "minor": 2575,
        "currency": "EUR"
      },
      "words"
    ],
    "expect": {
      "words": "Twenty-five euros and seventy-five cents only",
      "figures": "€25.75"
    }
  },
  {
    "name": "euro cents as figures",
    "args": [
      {
        "minor": 2575,
        "currency": "EUR"
      },
      "figures"
    ],
    "expect": {
      "words": "Twenty-five euros and 75c only",
      "figures": "€25.75"
    }
  },
  {
    "name": "dollars",
    "args": [
      {
        "minor": 199,
        "currency": "USD"
      },
      "figures"
    ],
    "expect": {
      "words": "One dollar and 99c only",
      "figures": "$1.99"
    }
  },
  {
    "name": "a zero cheque is an error",
    "args": [
      {
        "minor": 0,
        "currency": "GBP"
      },
      "words"
    ],
    "expectError": "a cheque amount must be greater than zero"
  },
  {
    "name": "a negative cheque is an error",
    "args": [
      {
        "minor": -500,
        "currency": "GBP"
      },
      "words"
    ],
    "expectError": "a cheque amount must be greater than zero"
  },
  {
    "name": "a currency without words is an error",
    "args": [
      {
        "minor": 500,
        "currency": "JPY"
      },
      "words"
    ],
    "expectError": "no words for currency \"JPY\""
  },
  {
    "name": "an unknown pence style is an error",
    "args": [
      {
        "minor": 500,
        "currency": "GBP"
      },
      "roman"
    ],
    "expectError": "unknown pence style"
  }
]