Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

1.2 KB
Raw Blame
<?php

describe('countryFlagEmoji', function () {
    it('returns the correct flag for a valid uppercase code', function () {
        expect(countryFlagEmoji('US'))->toBe('๐Ÿ‡บ๐Ÿ‡ธ');
    });

    it('is case-insensitive', function () {
        expect(countryFlagEmoji('us'))->toBe('๐Ÿ‡บ๐Ÿ‡ธ');
    });

    it('returns the globe fallback for invalid input', function (?string $input) {
        expect(countryFlagEmoji($input))->toBe('๐ŸŒ');
    })->with([
        'null' => [null],
        'empty' => [''],
        'three letters' => ['USA'],
        'non-letters' => ['1!'],
        'single letter' => ['U'],
    ]);
});

describe('countryName', function () {
    it('returns the English region name for a valid uppercase code', function () {
        expect(countryName('US'))->toBe('United States');
    });

    it('is case-insensitive', function () {
        expect(countryName('us'))->toBe('United States');
    });

    it('returns Unknown for invalid input', function (?string $input) {
        expect(countryName($input))->toBe('Unknown');
    })->with([
        'null' => [null],
        'empty' => [''],
        'unresolvable ZZ' => ['ZZ'],
        'unresolvable XX' => ['XX'],
        'three letters' => ['USA'],
        'non-letters' => ['1!'],
    ]);
});