summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/cloudfoundry/jibber_jabber/jibber_jabber_windows_test.go
blob: f325d981ef9e6fdd457f46aa6d7a0b524c247397 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// +build windows

package jibber_jabber_test

import (
	"regexp"

	. "github.com/cloudfoundry/jibber_jabber"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

const (
	LOCALE_REGEXP    = "^[a-z]{2}-[A-Z]{2}$"
	LANGUAGE_REGEXP  = "^[a-z]{2}$"
	TERRITORY_REGEXP = "^[A-Z]{2}$"
)

var _ = Describe("Windows", func() {
	BeforeEach(func() {
		locale, err := DetectIETF()
		Ω(err).Should(BeNil())
		Ω(locale).ShouldNot(BeNil())
		Ω(locale).ShouldNot(Equal(""))
	})

	Describe("#DetectIETF", func() {
		It("detects correct IETF locale", func() {
			locale, _ := DetectIETF()
			matched, _ := regexp.MatchString(LOCALE_REGEXP, locale)
			Ω(matched).Should(BeTrue())
		})
	})

	Describe("#DetectLanguage", func() {
		It("detects correct Language", func() {
			language, _ := DetectLanguage()
			matched, _ := regexp.MatchString(LANGUAGE_REGEXP, language)
			Ω(matched).Should(BeTrue())
		})
	})

	Describe("#DetectTerritory", func() {
		It("detects correct Territory", func() {
			territory, _ := DetectTerritory()
			matched, _ := regexp.MatchString(TERRITORY_REGEXP, territory)
			Ω(matched).Should(BeTrue())
		})
	})
})