receiver_test.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package notify
  15. import "testing"
  16. func TestMobileExt(t *testing.T) {
  17. cases := []struct {
  18. data SInternationalMobile
  19. want string
  20. }{
  21. {
  22. SInternationalMobile{
  23. Mobile: "+8612345678901",
  24. AreaCode: "+86",
  25. },
  26. "12345678901",
  27. },
  28. {
  29. SInternationalMobile{
  30. Mobile: "+8612345678901;ext=2",
  31. AreaCode: "+86",
  32. },
  33. "12345678901",
  34. },
  35. {
  36. SInternationalMobile{
  37. "+8812345678901",
  38. "+86",
  39. },
  40. "",
  41. },
  42. {
  43. SInternationalMobile{
  44. "+8612345678901",
  45. "",
  46. },
  47. "12345678901",
  48. },
  49. {
  50. SInternationalMobile{
  51. "+8612345678901;ext=2",
  52. "",
  53. },
  54. "12345678901",
  55. },
  56. {
  57. SInternationalMobile{
  58. "13811111111",
  59. "",
  60. },
  61. "13811111111",
  62. },
  63. {
  64. SInternationalMobile{
  65. "+85213811111111",
  66. "",
  67. },
  68. "13811111111",
  69. },
  70. }
  71. for _, c := range cases {
  72. temp := c.data
  73. temp.AcceptExtMobile()
  74. if temp.Mobile != c.want {
  75. t.Errorf("reset mobile err,old:%s,new:%s", c.data, temp)
  76. }
  77. }
  78. }